<template>
  <div class="goodList-container">
      <van-nav-bar fixed :title="title" left-text="返回" left-arrow @click-left="onClickLeft"/>
      <div class="content">
            <div class="good-content" v-for="item in goodlist" :key="item.id" @click="getgoodinfo(item.id)">
         <img :src="item.cover_img" alt="" class="goodimg">
        <div class="goodtitle">
          <p>
            商品名称：<span>{{item.name}}</span><br>
             市场价：<span>{{item.sale_price}}</span>
        
            </p>
        </div>
        
      </div>
      </div>
    
  </div>
</template>
<script>
export default {
    data(){
      return{
        goodlist:[],
        id:this.$route.query.id,
        title:this.$route.query.title,
        page:1,
        pageSize:8,
        keys:""
      }
    },
    created() {
      this.getgoodlist()
    },
    methods: {
       getgoodlist(){
         this.$http.get('v1/goods/getGoodsList/',{
           params:{
               cateId:this.id,
               page:this.page,
               pageSize:this.pageSize,
               keys:this.keys
           }
           
         }).then(res=>{
           console.dir(res)
           this.goodlist=res.data.data.goods
           console.log(res.data.data.goods)
         }).catch(err=>{
           console.dir(err)
         })
         
       },
       onClickLeft(){
         this.$router.push('/Category')
       },
       getgoodinfo(id){
         this.$router.push("/GoodsInfo/" + id)
       }
    },
    
}
</script>
<style lang="less">
    .content{
         margin-top:40px;
         .good-content{
        border:1px solid #ccc;
     
        margin: 10px 10px;
        .goodimg{
           width:100px;
           height:100px;
           float:left;
         }
        .goodtitle{
          margin-left:100px;
          height:100px;
          font-size:14px;
        }
    }
    }
   
</style>
